﻿using System;

using System.Collections.Generic;
using System.Text;
using Silvermoon.Controls;
using System.IO;
using System.Drawing;

namespace FileExplorer
{
    public static class FileUtil
    {
        public static void Populate(TreeView treeView, string path)
        {
            string[] dirs = Directory.GetDirectories(path);
            string[] files = Directory.GetFiles(path);
            Array.Sort(dirs);
            Array.Sort(files);
            treeView.BeginInit();
            treeView.Items.Clear();
            if (dirs.Length > 0)
            {
                treeView.Items.Add(new ItemHeader { Text = "Folders",Color=Color.Black });
            }
            foreach (string dir in dirs) treeView.Items.Add(new FileItem(dir, true));

            if (files.Length > 0)
            {
                treeView.Items.Add(new ItemHeader { Text = "Files", Color=Color.DarkRed });
            }
            foreach (string file in files) treeView.Items.Add(new FileItem(file, false));

            treeView.EndInit();

        }
    }
}
